package com.happyrecyclingstation.controller.ai;

import com.happyrecyclingstation.utils.CurrentHolder;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * AI接口
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/hr/chats")
public class HrChatAIController {

    private final ChatClient serviceChatClient;

    /**
     * HR筛选简历
     * @param content
     * @return
     */
    @GetMapping(produces = "text/html;charset=UTF-8")
    public Flux<String> serviceChatClient(String content) {
        int userId = CurrentHolder.getCurrentId();
        String prompt = "【用户ID: " + userId + "】" + content;
        return serviceChatClient.prompt()
                .user(prompt)
                .stream()
                .content();
    }
}
